home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-11-27 | 3.7 KB | 137 lines | [TEXT/PJMM] |
- unit ICGlobals;
-
- interface
-
- const
- M_File = 129;
- M_Edit = 130;
- M_Install = 131;
- M_Windows = 132;
-
- const
- EM_Undo = 1;
- (* *)
- EM_Cut = 3;
- EM_Copy = 4;
- EM_Paste = 5;
- EM_Clear = 6;
- EM_SelectAll = 7;
-
- const
- FM_New = 1;
- FM_Open = 2;
- FM_OpenInternetPreferences = 3;
- (* *)
- FM_Close = 5;
- FM_Save = 6;
- FM_SaveAs = 7;
- (* *)
- FM_Quit = 9;
-
- const
- IM_Install = 1;
- IM_Save = 2;
- IM_Remove = 3;
-
- const { Other OS constants, probably declared somewhere now }
- kSysEnvironsVersion = 1;
- kOSEvent = app4Evt; {event used by MultiFinder}
- kSuspendResumeMessage = 1; {high byte of suspend/resume event message}
- kResumeMask = 1; {bit of message field for resume vs. suspend}
- kMouseMovedMessage = $FA; {high byte of mouse-moved event message}
- kNoEvents = 0; {no events mask}
-
- var { set up by InitSystemGlobals }
- system7: boolean;
- has_appleEvents: boolean;
- has_findfolder: boolean;
- has_aliasMgr: boolean;
- has_newStdFile: boolean;
- has_HelpMgr: boolean;
- has_colorQD: boolean;
- has_components: boolean;
- app_resfile: integer;
- app_fs: FSSpec;
- in_foreground: boolean;
- quitNow: boolean;
- app_version: VersRec;
-
- procedure InitGlobals;
-
- function InForeground: boolean;
-
- type
- icAction = (acDoThis, acInstallComponent, acOpenWindow, acNewDocument, acOpenDocument, acCloseWindow, acSave, {}
- acQuit, acStartApplication, acGetExample, acChooseApplication, acRemoveComponent);
-
- procedure DisplayError (action: icAction; err: OSErr);
-
- implementation
-
- uses
- Processes, Components;
-
- procedure InitGlobals;
- var
- oe: OSErr;
- gv: longInt;
- pb: FCBPBRec;
- sysenv: sysEnvRec;
- versh: VersRecHndl;
- begin
- app_resfile := CurResFile;
- pb.ioNamePtr := @app_fs.name;
- pb.ioVRefNum := 0;
- pb.ioRefNum := app_resfile;
- pb.ioFCBIndx := 0;
- oe := PBGetFCBInfo(@pb, false);
- app_fs.vRefNum := pb.ioFCBVRefNum;
- app_fs.parID := pb.ioFCBParID;
- has_colorqd := (SysEnvirons(1, sysEnv) = noErr) & sysenv.hasColorQD; { Gestalt has a bug that causes hasColourQD to always be set }
- system7 := (Gestalt(gestaltSystemVersion, gv) = noErr) & (gv >= $0700);
- has_AppleEvents := (Gestalt(gestaltAppleEventsAttr, gv) = noErr) & (BTST(gv, gestaltAppleEventsPresent));
- has_findfolder := (Gestalt(gestaltFindFolderAttr, gv) = noErr) & (BTST(gv, gestaltFindFolderPresent));
- has_newStdFile := (Gestalt(gestaltStandardFileAttr, gv) = noErr) & (BTST(gv, gestaltStandardFile58));
- has_HelpMgr := (Gestalt(gestaltHelpMgrAttr, gv) = noErr) & (BTST(gv, gestaltHelpMgrPresent));
- has_aliasMgr := (Gestalt(gestaltAliasMgrAttr, gv) = noErr) & (BTST(gv, gestaltAliasMgrPresent));
- has_components := (Gestalt(gestaltComponentMgr, gv) = noErr) & (gv > 0);
- versh := VersRecHndl(Get1Resource('vers', 1));
- if versh <> nil then begin
- app_version := versh^^;
- end
- else begin
- app_version.numericVersion.version := 0;
- app_version.countryCode := 0;
- app_version.shortVersion := '';
- end; (* if *)
- end;
-
- function InForeground: boolean;
- var
- gv: longInt;
- ourpsn, frontpsn: ProcessSerialNumber;
- front: boolean;
- begin
- if (Gestalt(gestaltOSAttr, gv) = noErr) & (BTST(gv, gestaltLaunchControl)) then begin
- if (GetCurrentProcess(ourpsn) = noErr) & (GetFrontProcess(frontpsn) = noErr) then begin
- if SameProcess(ourpsn, frontpsn, front) = noErr then
- in_foreground := front;
- end;
- end;
- InForeground := in_foreground;
- end;
-
- procedure DisplayError (action: icAction; err: OSErr);
- var
- junk: integer;
- tmp: Str255;
- begin
- if (err <> noErr) and (err <> userCanceledErr) then begin
- InitCursor;
- GetIndString(tmp, 131, ord(action) + 1);
- ParamText(tmp, StringOf(err : 1), '', '');
- junk := StopAlert(140, nil);
- end; (* if *)
- end; (* DisplayError *)
-
- end. (* ICGlobals *)